package com.arpa.wms.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;


/**
 * @description 收货单类型
 *
 * @author xuyang
 * @date 2020/9/26 15:40
 **/
public enum ReceiveTypeEnum implements IEnum<String> {
    /**
     * 收货单类型
     */
    RECEIVE("0","采购入库"),
    RETURN("1","退货入库"),
    COUNTING("2","盘盈入库"),
    ALLOCATION("3","调拨入库"),
    INITIALIZATION("4", "期初入库"),
    // oms
    SALE_RETURN("5", "销售退货"),
    OTHER("6", "其他入库"),
    ;

    /**
     * 值
     */
    private final String value;

    /**
     * 描述
     */
    private final String desc;

    ReceiveTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String translate(String value){
        ReceiveTypeEnum item = map.get(value);
        if(item != null){
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }

    private static final Map<String, ReceiveTypeEnum> map = new HashMap();

    static {
        for(ReceiveTypeEnum item: values()){
            map.put(item.getValue(), item);
        }
    }

    public static ReceiveTypeEnum getEnumByValue(String value) {
        return map.get(value);
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return desc;
    }
}
